<?php
if(empty($lastUpdate)) $lastUpdate='';
$checkPageI = 0;

//$downloadURL='http://rockermono.nonlogic.org/projects/'; // this page is down at the time of release
$downloadURL='http://mono.ath.cx:8080/'; // alternative page
$updateURL=$downloadURL.'ruffy/info.txt';
$checkPage=true;
if($checkPageI<20 and !cmd('info')){
	$checkPage=false;
	$checkPageI++;
} else {
	$checkPageI=0;
}
if($checkPage){
	$updateFile=file_get_contents($updateURL);
	$updateFile=str_replace("\r",'',$updateFile);
	$updateFileA=explode("\n",$updateFile);
	$curUpdate=$updateFileA[1];
	$curVersion=$updateFileA[0];
	$intV=(float)$version;
	$intCV=(float)$curVersion;
	$pUpToDate=round($intV/$intCV*100,2);
	if($curUpdate!=$lastUpdate){
		$checkUpdate=true;
	} else if(cmd('info')){
		$checkUpdate=true;
	} else {
		$checkUpdate=false;
	}
	$updateMessage='';
	if($checkUpdate){
		if($pUpToDate!=100){
			$updateMessage="Latest version is $curVersion";
		}
		if(!empty($updateMessage)){ $updateMessage=', '.$updateMessage; }
		if(empty($updateFile)){
			reply("Update Information not available from $updateURL at this time");
		} else {
			$lastUpdate=$curUpdate;
			reply("Update Information '$curUpdate'. Core is $pUpToDate% up to date. [Running v".$version.$updateMessage."] Please see $downloadURL for more information.");
		}
	}
};

?>
